package prjtgl.bdd.comptes.interactions_utilisateur;

import java.util.List;
import org.hibernate.Query;
import prjtgl.bdd.HGeneral;
import prjtgl.metier.comptes.Membre;

/**
 * Classe permettant de gérer les contacts en BDD
 * @author Amirouche
 */
public class HContact extends HGeneral{
	public List<Membre> listerContacts(Membre m){
		session.beginTransaction();
		Query q;
		q = session.createQuery(
			"from Membre as m "
			+ "where m.id IN ( "
				+ "(select c.demandeur from Contact as c "
				+ "where c.demande = '" + m.getId() + "' )"
				+ " union "
				+ "(select c2.demande from Contact as c2 "
				+ "where c2.demandeur = '" + m.getId() +"' )"
			+ ")"
		
		);
		List<Membre> demandes = q.list();
		return demandes;
	}
}
